<template>
  <div class="table-page-search-wrapper">
    <el-form :model="form" ref="form" class="flex-form" :inline="true" label-width="100px">
      <el-row :gutter="10">
        <el-col :span="6">
          <el-form-item label="姓名" prop="userName">
            <el-input clearable v-model="form.userName" placeholder="输入姓名搜索" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="科室">
            <dept-select @select="handleDeptSelect" ref="deptSelect" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="考评方案名称" prop="moralityPlanName" class="mb0">
            <el-input clearable v-model="form.moralityPlanName" placeholder="输入方案名称搜索" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item>
            <el-tooltip class="item" content="查询" effect="dark" placement="top">
              <el-button type="primary" @click="handleSearch" icon="el-icon-search" />
            </el-tooltip>
            <el-tooltip class="item" content="重置" effect="dark" placement="top">
              <el-button @click="handleReset" icon="el-icon-refresh-right" />
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import DeptSelect from '@/components/DeptSelect'
export default {
  components: {
    DeptSelect
  },
  data() {
    return {
      name: null,
      form: {
        pageNo: 1
      }
    }
  },
  methods: {
    handleDeptSelect(value) {
      this.$set(this.form, 'deptId', value.key)
    },
    handleSearch() {
      this.$emit('search', this.form)
    },
    handleReset() {
      this.$refs.deptSelect.reset()
      this.$set(this.form, 'deptId', null)
      this.$refs.form.resetFields()
      this.$emit('search', this.form)
    }
  }
}
</script>

<style scoped>
.el-form-item {
  margin-bottom: 10px;
}

.flex-form >>> .el-form-item {
  display: flex;
}

.flex-form >>> .el-form-item .el-form-item__content,
.flex-form >>> .el-form-item .el-form-item__content .el-select {
  width: 100%;
}
</style>